serial 您所在的位置:网站首页 arduino serial serial1 serial

serial

2023-03-05 16:26| 来源: 网络整理| 查看: 265

Apologies if this a relatively simple question, but I am rather new to Arduino's and cannot seem to find any concise information on the topic. This is my XBee, mounted on a shield and placed onto a MEGA 2560. I want to leave Serial for USB debugging and use the Serial1 for XBee communication. enter image description here

Just to confirm, the two XBee's do communicate if I use SoftwareSerial. This is the code that works using SoftwareSerial:

#include // XBee's DOUT (TX) is connected to pin 10 (Arduino's Software RX) // XBee's DIN (RX) is connected to pin 11 (Arduino's Software TX) SoftwareSerial serial1(10, 11); // RX, TX boolean nextLine = false; void setup() { Serial.begin(9600); serial1.begin(9600); } void loop() { while(serial1.available()){ // there is data being sent from the xBee char read = char(serial1.read()); if(read == 'A'){ //Where ~ is the EOT character serial1.write("55.134~"); } } }

How do I communicate using Serial1?



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有